package com.chinaisafe.user.dto;

import com.chinaisafe.user.entity.SysUser;
import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Getter;
import lombok.Setter;
import lombok.ToString;
import lombok.experimental.Accessors;

import java.io.Serial;
import java.time.LocalDate;
import java.time.LocalDateTime;
import java.io.Serializable;

/**
 * SysUserDTO
 * Description：用户数据传输对象
 *
 * @author xuefu.shu
 * @date  2024-07-12 09:55:54
 */
@Getter
@Setter
@ToString
@Accessors(chain = true)
@Schema(name = "SysUserDTO", description = "用户数据传输对象")
public class SysUserDTO implements Serializable {

    @Serial
    private static final long serialVersionUID = 1L;

    @Schema(description = "主键id")
    private Long id;

    @Schema(description = "账号_id")
    private Long sysAccountId;

    @Schema(description = "用户扩展信息_id")
    private Long sysUserExtendId;

    @Schema(description = "账号")
    private String account;

    @Schema(description = "昵称")
    private String nickName;

    @Schema(description = "行政部门id")
    private Long administrationDeptId;

    @Schema(description = "手机号")
    private String mobile;

    @Schema(description = "邮箱")
    private String mail;

    @Schema(description = "身份证")
    private String identityCard;

    @Schema(description = "密码")
    private String password;

    @Schema(description = "帐号状态（0正常 1停用）")
    private Short status;

    @Schema(description = "头像")
    private String avatar;

    @Schema(description = "签名")
    private String signature;

    @Schema(description = "人脸")
    private String face;

    @Schema(description = "IMEI")
    private String imei;


    /**
     * 将实体类转换为数据传输对象
     * @param entity 实体对象
     * @return SysUserDTO 数据传输对象
     * @author xuefu.shu
     * @date 2024-07-12 09:55:54
     */
    public static SysUserDTO convertFromEntity(SysUser entity) {
        SysUserDTO dto = new SysUserDTO();
        dto.id = entity.getId();
        // 给对应的字段赋值 可根据实际业务删减
        dto.sysAccountId = entity.getSysAccountId();
        dto.sysUserExtendId = entity.getSysUserExtendId();
        dto.account = entity.getAccount();
        dto.nickName = entity.getNickName();
        dto.administrationDeptId = entity.getAdministrationDeptId();
        dto.mobile = entity.getMobile();
        dto.mail = entity.getMail();
        dto.identityCard = entity.getIdentityCard();
        dto.status = entity.getStatus();
        dto.avatar = entity.getAvatar();
        dto.signature = entity.getSignature();
        dto.face = entity.getFace();
        dto.imei = entity.getImei();
        return dto;
    }
}
